package com.xique.door.project.miniprogram.controller;

import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.project.miniprogram.bean.request.MiniVisitorCompleteInviteRequest;
import com.xique.door.project.miniprogram.bean.request.MiniVisitorInviteRequest;
import com.xique.door.project.miniprogram.biz.service.IMiniVisitorBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author shd
 * @create 2022/4/20 13:22
 */
@RestController
@RequestMapping("/visitor")
public class MiniVisitorController extends BaseController {

    @Autowired
    private IMiniVisitorBizService visitorBizService;

    @GetMapping("/invitationCode")
    public AjaxResult invitationCode() {
        return visitorBizService.getInvitationCode();
    }

    @PostMapping("/invite")
    public AjaxResult invite(@RequestBody @Valid MiniVisitorInviteRequest request) throws Exception {
        return visitorBizService.invite(request);
    }

    @PostMapping("/completeInvite")
    public AjaxResult completeInvite(@RequestBody @Valid MiniVisitorCompleteInviteRequest request) {
        return visitorBizService.completeInvite(request);
    }
}
